import {fileURLToPath, URL} from 'node:url'

import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'
import {API_BASE_PATH, BACKEND_URL} from './src/constants/api'

// https://vite.dev/config/
export default defineConfig({
  plugins: [
    vue({
      script: {
        propsDestructure: true
      }
    }),
    vueDevTools(),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    },
  },
  build: {
    sourcemap: true
  },
  server: {
    sourcemapIgnoreList: false,
    proxy: {
        [API_BASE_PATH]: {
            target: BACKEND_URL,
            changeOrigin: true
      }
    }
  },
  esbuild: {
    sourcemap: true,
  },
})